Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
unique-slug
Advanced tools
Package description
The unique-slug npm package is a simple utility for generating unique, random slugs that can be used for file names, URLs, unique identifiers, etc. It uses a combination of the current timestamp and a random string to ensure uniqueness.
Generate a unique slug
This feature generates a unique slug that can be used where a unique string is needed, such as for a unique filename or URL component.
const uniqueSlug = require('unique-slug');
const slug = uniqueSlug();
console.log(slug);
Generate a unique slug with a prefix
This feature allows for the generation of a unique slug with a specified prefix, which can be useful for categorizing or identifying the type of resource the slug represents.
const uniqueSlug = require('unique-slug');
const prefix = 'img_';
const slugWithPrefix = uniqueSlug(prefix);
console.log(slugWithPrefix);
Shortid is a package that generates short, non-sequential, URL-friendly unique ids. Unlike unique-slug, which combines a timestamp with a random string, shortid generates shorter identifiers that are easier to read and type. It's often used for URL shorteners or anywhere a shorter identifier is beneficial.
UUID is a package that generates RFC-compliant UUIDs (Universally Unique Identifiers). It provides different versions of UUIDs, such as v1 (timestamp-based) and v4 (random). While unique-slug generates a unique string based on timestamp and randomness, UUID provides a standardized format for unique identifiers, which can be important for interoperability and when a universally accepted unique identifier format is required.
NanoID is a tiny, secure URL-friendly unique string ID generator. It is similar to unique-slug in that it generates unique strings, but it offers a customizable alphabet and size, allowing for a wider range of possible IDs and control over the length of the generated ID. NanoID claims to be a more secure and compact alternative to UUID.
Changelog
Readme
Generate a unique character string suitible for use in files and URLs.
var uniqueSlug = require('unique-slug')
var randomSlug = uniqueSlug()
var fileSlug = uniqueSlug('/etc/passwd')
If str is passed in then the return value will be its murmur hash in hex.
If str is not passed in, it will be 4 randomly generated bytes converted into 8 hexadecimal characters.
FAQs
Generate a unique character string suitible for use in files and URLs.
The npm package unique-slug receives a total of 19,707,595 weekly downloads. As such, unique-slug popularity was classified as popular.
We found that unique-slug demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.